package com.sdo.bambooksdk;

public class BackupAllPrivateBook {

    static int currentProgress = 0;
    static String backupPath = "D:\\tempsnb\\";

    public static void main(String args[]) {
        int hConn = BBUtil.getConn();
        PrivBookInfo pInfo = new PrivBookInfo();
        pInfo.cbSize = pInfo.size();
        int result = BambookCore.INSTANCE.BambookGetFirstPrivBookInfo(hConn, pInfo);
        TransCallback pCallbackFunc = new TransCallback() {

            public void invoke(int status, int progress, int userData) {
                currentProgress = progress;
            }
        };
        while (Const.BR_SUCC == result) {
            String bookId = (new String(pInfo.bookGuid)).trim();
            if (bookId.indexOf(".snb") > 0) {
                result = BambookCore.INSTANCE.BambookFetchPrivBook(hConn, bookId, backupPath, pCallbackFunc, 0);
                while (currentProgress < 100) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ex) {
                    }
                }
            }
            result = BambookCore.INSTANCE.BambookGetNextPrivBookInfo(hConn, pInfo);
            currentProgress = 0;
        }
        BambookCore.INSTANCE.BambookDisconnect(hConn);
    }
}
